<template>
  <OverLay>
    <div class="dialog">
      <slot name="header">
        <div class="dialog-header">
          <h2 class="dialog-title">{{ dialogTitle }}</h2>
          <div class="dialog-close" @click="emit('cancel')">
            <i class="fas fa-times"></i>
          </div>
        </div>
      </slot>
      <div class="dialog-body">
        <slot name="body"></slot>
      </div>

      <div class="dialog-footer">
        <slot name="footer"></slot>
      </div>
    </div>
  </OverLay>
</template>

<script setup>
import OverLay from "./OverLay.vue"

const { dialogTitle } = defineProps({
  dialogTitle: {
    type: String,
    default: "",
  },
})
const emit = defineEmits(["cancel"])
</script>

<style scoped>
.dialog {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  width: 90%;
  max-width: 450px;
  overflow: hidden;
  transition: var(--transition);
}

.dialog-header {
  background: var(--primary);
  padding: 25px 30px;
  color: var(--text);
  text-align: center;
  position: relative;
}

.dialog-title {
  font-size: 1.8rem;
  font-weight: 600;
  margin: 0;
}

.dialog-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.dialog-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.dialog-body {
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
  padding: 20px 30px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}
</style>
